#include "../../../dxhead/dxegheader.h"
#include "../inc/xCamera.h"
#define SET_VIEW_XDIR(matView,vDir,vEyePos) matView._11 = vDir.x; matView._21 = vDir.y; matView._31 = vDir.z; matView._41 = - D3DXVec3Dot( (D3DXVECTOR3*)&vEyePos, (D3DXVECTOR3*)&vDir);
#define SET_VIEW_YDIR(matView,vDir,vEyePos) matView._12 = vDir.x; matView._22 = vDir.y; matView._32 = vDir.z; matView._42 = - D3DXVec3Dot( (D3DXVECTOR3*)&vEyePos, (D3DXVECTOR3*)&vDir);
#define SET_VIEW_ZDIR(matView,vDir,vEyePos) matView._13 = vDir.x; matView._23 = vDir.y; matView._33 = vDir.z; matView._43 = - D3DXVec3Dot( (D3DXVECTOR3*)&vEyePos, (D3DXVECTOR3*)&vDir);
#define SET_VIEW_MOVE(matView,vXDir,vYDir,vZDir,vEyePos)	matView._41 = - D3DXVec3Dot( (D3DXVECTOR3*)&vEyePos, (D3DXVECTOR3*)&vXDir); \
															matView._42 = - D3DXVec3Dot( (D3DXVECTOR3*)&vEyePos, (D3DXVECTOR3*)&vYDir);	\
															matView._43 = - D3DXVec3Dot( (D3DXVECTOR3*)&vEyePos, (D3DXVECTOR3*)&vZDir);
xRotator::xRotator()
{
	Reset();
}
xRotator::xRotator(D3DXQUATERNION* pStart)
{
	StartPosition(pStart);
}
xRotator::xRotator(D3DXVECTOR3* pvAxis,TFloat fAngle)
{
	StartPosition(pvAxis,fAngle);
}
TVoid				xRotator::Reset()
{
	D3DXQuaternionIdentity(&mqRotationAbs);
	D3DXQuaternionIdentity(&mqStartRotation);
	D3DXMatrixIdentity(&mmRotationAbs);
	D3DXMatrixIdentity(&mmRotationRel);
}
TVoid				xRotator::StartPosition(D3DXQUATERNION* pqRotate)
{
	mqRotationAbs=*pqRotate;
	D3DXQuaternionIdentity(&mqRotationAbs);
	mqStartRotation=mqRotationAbs;
	D3DXMatrixRotationQuaternion(&mmRotationAbs,&mqRotationAbs);
}
TVoid				xRotator::StartPosition(D3DXVECTOR3* pvAxis,TFloat fAngle)
{
	D3DXQuaternionRotationAxis(&mqRotationAbs,pvAxis,fAngle);
	StartPosition(&mqRotationAbs);
}
const D3DXMATRIX*	xRotator::RotateRel(D3DXQUATERNION* pqRotate)
{
	D3DXQuaternionMultiply(&mqRotationAbs,&mqRotationAbs,pqRotate);
	D3DXMatrixRotationQuaternion(&mmRotationAbs,&mqRotationAbs);
	return D3DXMatrixRotationQuaternion(&mmRotationRel,pqRotate);
}
const D3DXMATRIX*	xRotator::RotateRel(D3DXVECTOR3* pvAxis,TFloat fAngle)
{
	D3DXQUATERNION qAdd;
	D3DXQuaternionRotationAxis(&qAdd,pvAxis,fAngle);
	return RotateRel(&qAdd);
}
const D3DXMATRIX*	xRotator::RotateAbs(D3DXQUATERNION* pqRotate)
{
	D3DXQuaternionMultiply(&mqRotationAbs,&mqStartRotation,pqRotate);
	mmRotationRel = mmRotationAbs;
	return D3DXMatrixRotationQuaternion(&mmRotationAbs,&mqRotationAbs);
}
const D3DXMATRIX*	xRotator::RotateAbs(D3DXVECTOR3* pvAxis,TFloat fAngle)
{
	D3DXQUATERNION qAdd;
	D3DXQuaternionRotationAxis(&qAdd,pvAxis,fAngle);
	return RotateAbs(&qAdd);
}
const D3DXMATRIX*	xRotator::GetRotationMatrixAbs()
{
	return &mmRotationAbs;
}
const D3DXMATRIX*	xRotator::GetRotationMatrixRel()
{
	return &mmRotationRel;
}
//
xCamera::xCamera(TVoid)
{	
	mvDefaultEyePos =D3DXVECTOR4(0.0f,0.0f,-1.0f,0.0f);
	mvDefaultZDir	=D3DXVECTOR4(0.0f,0.0f,1.0f,0.0f);
	mvDefaultYDir	=D3DXVECTOR4(0.0f,1.0f,0.0f,0.0f);
	mvDefaultXDir	=D3DXVECTOR4(1.0f,0.0f,0.0f,0.0f);
	ResetView();
}

xCamera::~xCamera(TVoid)
{
}
const D3DXMATRIX*  xCamera::GetViewMatrix()	const{ return &mmView; }
const D3DXMATRIX*  xCamera::GetProjMatrix()	const{ return &mmProj; }
const D3DXVECTOR3* xCamera::GetPos()		const{ return (D3DXVECTOR3*)&mvEyePos; }
const D3DXVECTOR3* xCamera::GetZDir()		const{ return (D3DXVECTOR3*)&mvZDir; }
const D3DXVECTOR3* xCamera::GetYDir()		const{ return (D3DXVECTOR3*)&mvYDir; }
const D3DXVECTOR3* xCamera::GetXDir()		const{ return (D3DXVECTOR3*)&mvXDir; }
TFloat	xCamera::GetNearClip()				const{ return mfNearPlane;}
TFloat	xCamera::GetFarClip()				const{ return mfFarPlane; }
TVoid	xCamera::SetViewParams( D3DXVECTOR3* pvEyePos,D3DXVECTOR3* pvZDir, D3DXVECTOR3* pvYDir )
{

	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir, pvZDir);

	D3DXVec3Cross( (D3DXVECTOR3*)&mvXDir, pvYDir, pvZDir );
	D3DXVec3Normalize( (D3DXVECTOR3*)&mvXDir, (D3DXVECTOR3*)&mvXDir);

	D3DXVec3Cross( (D3DXVECTOR3*)&mvYDir, (D3DXVECTOR3*)&mvZDir, (D3DXVECTOR3*)&mvXDir );
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir, (D3DXVECTOR3*)&mvYDir);

	mvEyePos.x = pvEyePos->x; mvEyePos.y = pvEyePos->y;
	mvEyePos.z = pvEyePos->z; mvEyePos.w = 1.0f;
	mvZDir.w = 1.0f;
	mvXDir.w = 1.0f;
	mvYDir.w = 1.0f;
	mvDefaultEyePos	= mvEyePos;
	mvDefaultZDir	= mvZDir;
	mvDefaultYDir	= mvYDir;
	mvDefaultXDir	= mvXDir;
	
	// Build the view matrix
	//x rotation			 y rotation				z rotation
	//mmView._11 = mvXDir.x; mmView._12 = mvYDir.x; mmView._13 = mvZDir.x; mmView._14 = 0	;
	//mmView._21 = mvXDir.y; mmView._22 = mvYDir.y; mmView._23 = mvZDir.y; mmView._24 = 0	;

	//x translation
	//mmView._41 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir );
	//y translation
	//mmView._42 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir );
	//z translation
	//mmView._43 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir );
	//mmView._44 = 1.0f;

	D3DXMatrixIdentity(&mmView);
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
	D3DXMatrixLookAtLH( &mmView, pvEyePos, pvZDir, pvYDir );

}
TVoid	xCamera::SetProjParams( TFloat fFOV, TFloat fAspect, TFloat fNearPlane, TFloat fFarPlane )
{
	mfFOV        = fFOV;
    mfAspect     = fAspect;
    mfNearPlane  = fNearPlane;
    mfFarPlane   = fFarPlane;
    D3DXMatrixPerspectiveFovLH( &mmProj, fFOV, fAspect, fNearPlane, fFarPlane );
}
TVoid	xCamera::ResetView()
{
	mvEyePos	=mvDefaultEyePos;
	mvZDir		=mvDefaultZDir;
	mvYDir		=mvDefaultYDir;
	mvXDir		=mvDefaultXDir;
	// Build the view matrix
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
	/*mmView._11 = mvXDir.x; mmView._12 = mvYDir.x; mmView._13 = mvZDir.x;
    mmView._21 = mvXDir.y; mmView._22 = mvYDir.y; mmView._23 = mvZDir.y;
    mmView._31 = mvXDir.z; mmView._32 = mvYDir.z; mmView._33 = mvZDir.z;

    mmView._41 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir );
	mmView._42 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
	mmView._43 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir );*/

}
//
xFPCamera::xFPCamera():
mvCenter(D3DXVECTOR3(0.0f,0.0f,0.0f))
{

}
xFPCamera::~xFPCamera()
{

}
TVoid	xFPCamera::BuildRotateX()
{
	const D3DXMATRIX *mpRot = Rotator.GetRotationMatrixRel();
	D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvZDir,mpRot);
	D3DXVec3Cross((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvXDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvYDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
	/*mmView._12 = mvYDir.x; mmView._13 = mvZDir.x;
	mmView._22 = mvYDir.y; mmView._23 = mvZDir.y;
	mmView._32 = mvYDir.z; mmView._33 = mvZDir.z;
	mmView._42 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
	mmView._43 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);*/
	
}
TVoid	xFPCamera::BuildRotateY()
{
	const D3DXMATRIX *mpRot=Rotator.GetRotationMatrixRel();
	D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvZDir,mpRot);
	D3DXVec3Cross((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvXDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
	/*mmView._11 = mvXDir.x; mmView._13 = mvZDir.x;
	mmView._21 = mvXDir.y; mmView._23 = mvZDir.y;
	mmView._31 = mvXDir.z; mmView._33 = mvZDir.z;
	mmView._41 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	mmView._43 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);*/
	
}
TVoid	xFPCamera::BuildRotateZ()
{
	const D3DXMATRIX *mpRot=Rotator.GetRotationMatrixRel();
	D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvXDir,mpRot);
	D3DXVec3Cross((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvXDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvYDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvXDir);
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	/*mmView._11 = mvXDir.x; mmView._12 = mvYDir.x;
    mmView._21 = mvXDir.y; mmView._22 = mvYDir.y;
    mmView._31 = mvXDir.z; mmView._32 = mvYDir.z;
	mmView._41 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	mmView._42 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);*/
	
}
TVoid	xFPCamera::BuildRotate()
{
	const D3DXMATRIX *mpRot = Rotator.GetRotationMatrixRel();
	D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvDefaultXDir,mpRot);
	D3DXVec3Transform(&mvYDir,(D3DXVECTOR3*)&mvDefaultYDir,mpRot);
	D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvDefaultZDir,mpRot);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvYDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Cross((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir);
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
	//mmView._11 = mvXDir.x; mmView._12 = mvYDir.x;mmView._13 = mvZDir.x;
	//mmView._21 = mvXDir.y; mmView._22 = mvYDir.y;mmView._23 = mvZDir.y;
	//mmView._31 = mvXDir.z; mmView._32 = mvYDir.z;mmView._33 = mvZDir.z;
	//mmView._41 = - D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	//mmView._42 = - D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
	//mmView._43 = - D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);
	
}
TVoid	xFPCamera::BuildMove()
{
	SET_VIEW_MOVE(mmView,mvXDir,mvYDir,mvZDir,mvEyePos);
	/*mmView._41 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	mmView._42 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
	mmView._43 =- D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);*/
}

TVoid	xFPCamera::RotateYRel(TFloat angle)
{
	Rotator.RotateRel((D3DXVECTOR3*)&mvYDir,angle);
	return BuildRotateY();
}
TVoid	xFPCamera::RotateYAbs(TFloat angle)
{
	Rotator.RotateAbs((D3DXVECTOR3*)&mvYDir,angle);
	return BuildRotateY();
}

TVoid	xFPCamera::RotateXRel(TFloat angle)
{
	Rotator.RotateRel((D3DXVECTOR3*)&mvXDir,angle);
	return BuildRotateX();
}
TVoid	xFPCamera::RotateXAbs(TFloat angle)
{
	Rotator.RotateAbs((D3DXVECTOR3*)&mvXDir,angle);
	return BuildRotateX();
}
TVoid	xFPCamera::RotateZRel(TFloat angle)
{
	Rotator.RotateRel((D3DXVECTOR3*)&mvZDir,angle);
	return BuildRotateZ();
}
TVoid	xFPCamera::RotateZAbs(TFloat angle)
{
	Rotator.RotateAbs((D3DXVECTOR3*)&mvZDir,angle);
	return BuildRotateZ();
}
TVoid	xFPCamera::RotateRel(D3DXVECTOR3* pAxis,TFloat Angle)
{
	Rotator.RotateRel((D3DXVECTOR3*)pAxis,Angle);
	return BuildRotate();
}
TVoid	xFPCamera::RotateAbs(D3DXVECTOR3* pAxis,TFloat Angle)
{
	Rotator.RotateAbs((D3DXVECTOR3*)pAxis,Angle);
	return BuildRotate();
}
TVoid	xFPCamera::MoveZRel(TFloat dist)
{
	D3DXVECTOR4 vDis = mvZDir * dist;
	mvEyePos += vDis;
	return BuildMove();
}
TVoid	xFPCamera::MoveZAbs(TFloat dist)
{
	mvEyePos=mvDefaultEyePos+mvZDir*dist;
	return BuildMove();
}
TVoid	xFPCamera::MoveXRel(TFloat dist)
{
	D3DXVECTOR4 vDis = mvXDir*dist;
	mvEyePos += vDis;
	return BuildMove();
}
TVoid	xFPCamera::MoveXAbs(TFloat dist)
{
	mvEyePos=mvDefaultEyePos+mvXDir*dist;
	return BuildMove();
}
TVoid	xFPCamera::MoveYRel(TFloat dist)
{
	D3DXVECTOR4 vDis = mvYDir * dist;
	mvEyePos += vDis;
	return BuildMove();
}
TVoid	xFPCamera::MoveYAbs(TFloat dist)
{
	mvEyePos=mvDefaultEyePos+mvYDir*dist;
	return BuildMove();
}
TVoid	xFPCamera::MoveRel(D3DXVECTOR3* dist)
{
	D3DXVECTOR4 vDis = D3DXVECTOR4(dist->x,dist->y,dist->z,0);
	mvEyePos.x+=dist->x;
	mvEyePos.y+=dist->y;
	mvEyePos.z+=dist->z;
	return BuildMove();
}
TVoid	xFPCamera::MoveAbs(D3DXVECTOR3* pDist)
{
	mvEyePos.x =mvDefaultEyePos.x+pDist->x;
	mvEyePos.y =mvDefaultEyePos.y+pDist->y;
	mvEyePos.z =mvDefaultEyePos.z+pDist->z;
	return BuildMove();
}
//
xMVCamera::xMVCamera():
mvCenter(D3DXVECTOR3(0.0f,0.0f,0.0f))
{
}
xMVCamera::xMVCamera(D3DXVECTOR3 Center):
mvCenter(Center)
{
}
TVoid	xMVCamera::SetCenter(D3DXVECTOR3* pCenter)
{
	mvCenter=*pCenter;
	*(D3DXVECTOR3*)&mvZDir = (D3DXVECTOR3)mvCenter - (D3DXVECTOR3)mvEyePos;
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Cross((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvXDir);
	mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);

}
TVoid	xMVCamera::SetRadius(TFloat fRadius)
{
	D3DXVECTOR3 mvRadius = -fRadius*(D3DXVECTOR3)mvZDir;

	mvCenter.x = mvEyePos.x - mvRadius.x;
	mvCenter.y = mvEyePos.y - mvRadius.y;
	mvCenter.z = mvEyePos.z - mvRadius.z;

	mvDefaultEyePos.x=mvEyePos.x;
	mvDefaultEyePos.y=mvEyePos.y;
	mvDefaultEyePos.z=mvEyePos.z;
	SET_VIEW_MOVE(mmView,mvXDir,mvYDir,mvZDir,mvEyePos);
}

TVoid	xMVCamera::BuildRotateX()
{
	*(D3DXVECTOR3*)&mvZDir = *(D3DXVECTOR3*)&mvCenter - *(D3DXVECTOR3*)&mvEyePos;
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Cross((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvXDir);
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
	mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
}
TVoid	xMVCamera::RotateXRel(TFloat Angle)
{
	D3DXVECTOR3 mvRadius;
	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
	Rotator.RotateRel((D3DXVECTOR3*)&mvYDir,Angle);
	const D3DXMATRIX * mpRot=Rotator.GetRotationMatrixRel();
	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);
	mvEyePos.x += mvCenter.x ;
	mvEyePos.y += mvCenter.y ;
	mvEyePos.z += mvCenter.z ;
	BuildRotateX();
}
TVoid	xMVCamera::RotateXAbs(TFloat Angle)
{
	D3DXVECTOR3 mvRadius;
	mvRadius = (D3DXVECTOR3)mvDefaultEyePos - mvCenter;
	Rotator.RotateAbs((D3DXVECTOR3*)&mvDefaultXDir,Angle);
	const D3DXMATRIX * mpRot=Rotator.GetRotationMatrixAbs();
	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);
	D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvDefaultZDir,mpRot);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	mvEyePos.x = mvCenter.x ;
	mvEyePos.y = mvCenter.y ;
	mvEyePos.z = mvCenter.z ;
	BuildRotateX();
}
TVoid	xMVCamera::BuildRotateY()
{
	*(D3DXVECTOR3*)&mvZDir = *(D3DXVECTOR3*)&mvCenter - *(D3DXVECTOR3*)&mvEyePos;
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Cross((D3DXVECTOR3*)&mvYDir, (D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvXDir);	
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvYDir);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
	mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	//mmView._11 = mvXDir.x; mmView._13 = mvZDir.x;
	//mmView._21 = mvXDir.y; mmView._23 = mvZDir.y;
	//mmView._31 = mvXDir.z; mmView._33 = mvZDir.z;
	//mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	//mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
	//mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);
}
TVoid	xMVCamera::RotateYRel(TFloat Angle)
{
	D3DXVECTOR3 mvRadius;
	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
	Rotator.RotateRel((D3DXVECTOR3*)&mvXDir,Angle);
	const D3DXMATRIX * mpRot=Rotator.GetRotationMatrixRel();
	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);
	mvEyePos.x += mvCenter.x ;
	mvEyePos.y += mvCenter.y ;
	mvEyePos.z += mvCenter.z ;	
	
	BuildRotateY();
}
TVoid	xMVCamera::RotateYAbs(TFloat Angle)
{
	D3DXVECTOR3 mvRadius;
	mvRadius = (D3DXVECTOR3)mvDefaultEyePos - mvCenter;
	Rotator.RotateAbs((D3DXVECTOR3*)&mvDefaultXDir,Angle);
	const D3DXMATRIX * mpRot=Rotator.GetRotationMatrixAbs();
	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);
	mvEyePos.x += mvCenter.x ;
	mvEyePos.y += mvCenter.y ;
	mvEyePos.z += mvCenter.z ;	
	BuildRotateY();
}
TVoid	xMVCamera::BuildRotateZ()
{
	D3DXVec3Cross((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvXDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvXDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvYDir);
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);
	//mmView._11 = mvXDir.x; mmView._12 = mvYDir.x;
	//mmView._21 = mvXDir.y; mmView._22 = mvYDir.y;
	//mmView._31 = mvXDir.z; mmView._32 = mvYDir.z;
	//mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	//mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
	//mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);
}
TVoid	xMVCamera::RotateZRel(TFloat Angle)
{
	D3DXVECTOR3 mvRadius;
	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
	Rotator.RotateRel((D3DXVECTOR3*)&mvZDir,Angle);
	const D3DXMATRIX * mpRot=Rotator.GetRotationMatrixRel();
	D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvXDir,mpRot);
	
	mvEyePos.x += mvCenter.x ;
	mvEyePos.y += mvCenter.y ;
	mvEyePos.z += mvCenter.z ;
	BuildRotateZ();
}
TVoid	xMVCamera::RotateZAbs(TFloat Angle)
{
	D3DXVECTOR3 mvRadius;
	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
	Rotator.RotateAbs((D3DXVECTOR3*)&mvZDir,Angle);
	const D3DXMATRIX * mpRot=Rotator.GetRotationMatrixAbs();
	D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvDefaultXDir,mpRot);

	mvEyePos.x = mvCenter.x ;
	mvEyePos.y = mvCenter.y ;
	mvEyePos.z = mvCenter.z ;
	BuildRotateZ();
}
TVoid	xMVCamera::RotateRel(D3DXVECTOR3* pAxis,TFloat Angle)
{
	D3DXVECTOR3 mvRadius;
	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
	Rotator.RotateRel((D3DXVECTOR3*)pAxis,Angle);
	const D3DXMATRIX * mpRot=Rotator.GetRotationMatrixRel();
	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);

	mvEyePos.x += mvCenter.x ;
	mvEyePos.y += mvCenter.y ;
	mvEyePos.z += mvCenter.z ;

	D3DXVec3Transform(&mvYDir,(D3DXVECTOR3*)&mvDefaultYDir,mpRot);
	D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvDefaultXDir,mpRot);
	D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvDefaultZDir,mpRot);
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
	/*mmView._11 = mvXDir.x; mmView._12 = mvYDir.x;mmView._13 = mvZDir.x;
    mmView._21 = mvXDir.y; mmView._22 = mvYDir.y;mmView._23 = mvZDir.y;
    mmView._31 = mvXDir.z; mmView._32 = mvYDir.z;mmView._33 = mvZDir.z;
	mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
	mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);*/
}
TVoid	xMVCamera::RotateAbs(D3DXVECTOR3* pAxis,TFloat Angle)
{	
	D3DXVECTOR3 mvRadius;
	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
	Rotator.RotateAbs((D3DXVECTOR3*)pAxis,Angle);
	const D3DXMATRIX * mpRot=Rotator.GetRotationMatrixAbs();
	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);

	mvEyePos.x += mvCenter.x ;
	mvEyePos.y += mvCenter.y ;
	mvEyePos.z += mvCenter.z ;

	D3DXVec3Transform(&mvYDir,(D3DXVECTOR3*)&mvDefaultYDir,mpRot);
	D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvDefaultXDir,mpRot);
	D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvDefaultZDir,mpRot);
	SET_VIEW_XDIR(mmView,mvXDir,mvEyePos);
	SET_VIEW_YDIR(mmView,mvYDir,mvEyePos);
	SET_VIEW_ZDIR(mmView,mvZDir,mvEyePos);
}
TVoid	xMVCamera::MoveRel(D3DXVECTOR3* Dist)
{

	mvEyePos.x += Dist->x;
	mvEyePos.y += Dist->y;
	mvEyePos.z += Dist->z;
	mvZDir.x = mvCenter.x - mvEyePos.x;
	mvZDir.y = mvCenter.y - mvEyePos.y;
	mvZDir.z = mvCenter.z - mvEyePos.z;
	*(D3DXVECTOR3*)&mvXDir = *Dist;
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Cross((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir, (D3DXVECTOR3*)&mvXDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvYDir);
	SET_VIEW_XDIR(mmView, mvXDir, mvEyePos);
	SET_VIEW_YDIR(mmView, mvYDir, mvEyePos);
	SET_VIEW_ZDIR(mmView, mvZDir, mvEyePos);
}
TVoid	xMVCamera::MoveAbs(D3DXVECTOR3* Dist)
{

	mvEyePos.x = Dist->x;
	mvEyePos.y = Dist->y;
	mvEyePos.z = Dist->z;
	mvZDir.x = mvCenter.x - mvEyePos.x;
	mvZDir.y = mvCenter.y - mvEyePos.y;
	mvZDir.z = mvCenter.z - mvEyePos.z;
	*(D3DXVECTOR3*)&mvXDir = *Dist;
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Cross((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir, (D3DXVECTOR3*)&mvXDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvYDir);
	SET_VIEW_XDIR(mmView, mvXDir, mvEyePos);
	SET_VIEW_YDIR(mmView, mvYDir, mvEyePos);
	SET_VIEW_ZDIR(mmView, mvZDir, mvEyePos);
}
TVoid	xMVCamera::BuildMoveX()
{
	mvZDir.x = mvCenter.x - mvEyePos.x;
	mvZDir.y = mvCenter.y - mvEyePos.y;
	mvZDir.z = mvCenter.z - mvEyePos.z;
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Cross((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvYDir, (D3DXVECTOR3*)&mvZDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvXDir,(D3DXVECTOR3*)&mvXDir);
	SET_VIEW_XDIR(mmView, mvXDir, mvEyePos);
	SET_VIEW_ZDIR(mmView, mvZDir, mvEyePos);
	//mmView._41 = -D3DXVec3Dot((D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	mmView._42 = -D3DXVec3Dot((D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
}
TVoid	xMVCamera::MoveXRel(TFloat Dist)
{
	D3DXVECTOR3 mvXMove;
	mvXMove = (D3DXVECTOR3)mvXDir * Dist;
	mvEyePos.x += mvXMove.x;
	mvEyePos.y += mvXMove.y;
	mvEyePos.z += mvXMove.z;
	BuildMoveX();
}
TVoid	xMVCamera::MoveXAbs(TFloat Dist)
{
	D3DXVECTOR3 mvXMove;
	mvXMove = (D3DXVECTOR3)mvXDir * Dist;
	mvEyePos.x = mvXMove.x;
	mvEyePos.y = mvXMove.y;
	mvEyePos.z = mvXMove.z;
	BuildMoveX();
}
TVoid	xMVCamera::BuildMoveY()
{
	mvZDir.x = mvCenter.x - mvEyePos.x;
	mvZDir.y = mvCenter.y - mvEyePos.y;
	mvZDir.z = mvCenter.z - mvEyePos.z;
	D3DXVec3Normalize((D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvZDir);
	D3DXVec3Cross((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir, (D3DXVECTOR3*)&mvXDir);
	D3DXVec3Normalize((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvYDir);
	SET_VIEW_YDIR(mmView, mvYDir, mvEyePos);
	SET_VIEW_ZDIR(mmView, mvZDir, mvEyePos);
	mmView._41 = -D3DXVec3Dot((D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
}
TVoid	xMVCamera::MoveYRel(TFloat Dist)
{
	D3DXVECTOR3 mvYMove;
	mvYMove = (D3DXVECTOR3)mvYDir * Dist;
	mvEyePos.x += mvYMove.x;
	mvEyePos.y += mvYMove.y;
	mvEyePos.z += mvYMove.z;
	BuildMoveY();
}
TVoid	xMVCamera::MoveYAbs(TFloat Dist)
{
	D3DXVECTOR3 mvYMove;
	mvYMove = (D3DXVECTOR3)mvYDir * Dist;
	mvEyePos.x = mvYMove.x;
	mvEyePos.y = mvYMove.y;
	mvEyePos.z = mvYMove.z;
	BuildMoveY();
}
TVoid	xMVCamera::BuildMoveZ()
{
	SET_VIEW_ZDIR(mmView, mvZDir, mvEyePos);
	mmView._41 = -D3DXVec3Dot((D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
	mmView._42 = -D3DXVec3Dot((D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
}
TVoid	xMVCamera::MoveZRel(TFloat Dist)
{
	D3DXVECTOR3 mvZMove;
	mvZMove = (D3DXVECTOR3)mvZDir * Dist;
	mvEyePos.x += mvZMove.x;
	mvEyePos.y += mvZMove.y;
	mvEyePos.z += mvZMove.z;
	BuildMoveZ();
}
TVoid	xMVCamera::MoveZAbs(TFloat Dist)
{
	D3DXVECTOR3 mvZMove;
	mvZMove = (D3DXVECTOR3)mvZDir * Dist;
	mvEyePos.x = mvZMove.x;
	mvEyePos.y = mvZMove.y;
	mvEyePos.z = mvZMove.z;
	BuildMoveZ();
}
//
//xGPCamera::xGPCamera()
////mvCenter(D3DXVECTOR3(0.0f,0.0f,0.0f))
////mvRadius(D3DXVECTOR3(0.0f,0.0f,1.0f))
//{
//	/*mfRadius = 1.0f;
//	mbLookAtCenter = vFalse;*/
//}
//TVoid	xGPCamera::SetCenter(D3DXVECTOR3* pCenter)
//{
//	mvCenter = *pCenter;
//	D3DXVECTOR3 vZdir = *pCenter - *(D3DXVECTOR3*)&mvEyePos;
//	D3DXVECTOR3 vYdir;
//
//	D3DXVec3Cross(&vYdir,(D3DXVECTOR3*)&vZdir,(D3DXVECTOR3*)&mvXDir);
//	SetViewParams((D3DXVECTOR3*)&mvEyePos,&vZdir,(D3DXVECTOR3*)&vYdir);
//	/*mvRadius.x = mvDefaultEyePos.x- mvCenter.x;
//	mvRadius.y = mvDefaultEyePos.y- mvCenter.y;
//	mvRadius.z = mvDefaultEyePos.z- mvCenter.z;*/
//}
//TVoid	xGPCamera::SetRadius(TFloat fRadius)
//{
//	D3DXVECTOR3 mvRadius = (D3DXVECTOR3)mvZDir * fRadius;
//	mvEyePos.x = mvCenter.x + mvRadius.x;
//	mvEyePos.y = mvCenter.y + mvRadius.y;
//	mvEyePos.z = mvCenter.z + mvRadius.z;
//	SET_VIEW_MOVE(mmView,mvXDir,mvYDir,mvZDir,mvEyePos);
//	/*mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
//	mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
//	mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);*/
//}
//TVoid	xGPCamera::OrbitAxisYRel(TFloat Angle)
//{
//	D3DXVECTOR3 mvRadius;
//	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
//	mOrbitRotator.RotateRel((D3DXVECTOR3*)&mvYDir,Angle);
//	const D3DXMATRIX * mpRot=mOrbitRotator.GetRotationMatrixRel();
//	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);
//
//	mvEyePos.x += mvCenter.x ;
//	mvEyePos.y += mvCenter.y ;
//	mvEyePos.z += mvCenter.z ;
//
//	//D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvDefaultXDir,mpRot);
//	//D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvDefaultZDir,mpRot);
//	//mmView._11 = mvXDir.x; mmView._13 = mvZDir.x;
//	//mmView._21 = mvXDir.y; mmView._23 = mvZDir.y;
//	//mmView._31 = mvXDir.z; mmView._33 = mvZDir.z;
//	SET_VIEW_MOVE(mmView,mvXDir,mvYDir,mvZDir,mvEyePos);
//	//mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
//	//mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
//	//mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);
//}
//TVoid	xGPCamera::OrbitAxisXRel(TFloat Angle)
//{
//	D3DXVECTOR3 mvRadius ;
//	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
//
//	mOrbitRotator.RotateRel((D3DXVECTOR3*)&mvXDir,Angle);
//	const D3DXMATRIX * mpRot=mOrbitRotator.GetRotationMatrixRel();
//	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);
//
//	mvEyePos.x += mvCenter.x ;
//	mvEyePos.y += mvCenter.y ;
//	mvEyePos.z += mvCenter.z ;
//
//	//D3DXVec3Transform(&mvYDir,(D3DXVECTOR3*)&mvYDir,mpRot);
//	//D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvZDir,mpRot);
//	//D3DXVec3Cross((D3DXVECTOR3*)&mvYDir,(D3DXVECTOR3*)&mvZDir,(D3DXVECTOR3*)&mvXDir);
//
//	//mmView._12 = mvYDir.x; mmView._13 = mvZDir.x;
//	//mmView._22 = mvYDir.y; mmView._23 = mvZDir.y;
//	//mmView._32 = mvYDir.z; mmView._33 = mvZDir.z;
//	SET_VIEW_MOVE(mmView,mvXDir,mvYDir,mvZDir,mvEyePos);
//	/*mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
//	mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
//	mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);*/
//}
//TVoid	xGPCamera::OrbitAxisZRel(TFloat Angle)
//{
//	D3DXVECTOR3 mvRadius ;
//	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
//
//
//	mOrbitRotator.RotateRel((D3DXVECTOR3*)&mvZDir,Angle);
//	const D3DXMATRIX * mpRot=mOrbitRotator.GetRotationMatrixRel();
//	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);
//
//	mvEyePos.x += mvCenter.x ;
//	mvEyePos.y += mvCenter.y ;
//	mvEyePos.z += mvCenter.z ;
//
//	//D3DXVec3Transform(&mvYDir,(D3DXVECTOR3*)&mvDefaultYDir,mpRot);
//	//D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvDefaultXDir,mpRot);
//	//mmView._11 = mvXDir.x; mmView._12 = mvYDir.x;
//	//mmView._21 = mvXDir.y; mmView._22 = mvYDir.y;
//	//mmView._31 = mvXDir.z; mmView._32 = mvYDir.z;
//
//	mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
//	mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
//	mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);
//}
//TVoid	xGPCamera::OrbitAxisRel(D3DXVECTOR3* pAxis,TFloat Angle)
//{
//	D3DXVECTOR3 mvRadius;
//	mvRadius = (D3DXVECTOR3)mvEyePos - mvCenter;
//
//	mOrbitRotator.RotateRel((D3DXVECTOR3*)pAxis,Angle);
//	const D3DXMATRIX * mpRot=mOrbitRotator.GetRotationMatrixRel();
//	D3DXVec3Transform(&mvEyePos,&mvRadius,mpRot);
//
//	mvEyePos.x += mvCenter.x ;
//	mvEyePos.y += mvCenter.y ;
//	mvEyePos.z += mvCenter.z ;
//
//	D3DXVec3Transform(&mvYDir,(D3DXVECTOR3*)&mvDefaultYDir,mpRot);
//	D3DXVec3Transform(&mvXDir,(D3DXVECTOR3*)&mvDefaultXDir,mpRot);
//	D3DXVec3Transform(&mvZDir,(D3DXVECTOR3*)&mvDefaultZDir,mpRot);
//	mmView._11 = mvXDir.x; mmView._12 = mvYDir.x;mmView._13 = mvZDir.x;
//    mmView._21 = mvXDir.y; mmView._22 = mvYDir.y;mmView._23 = mvZDir.y;
//    mmView._31 = mvXDir.z; mmView._32 = mvYDir.z;mmView._33 = mvZDir.z;
//	mmView._41 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvXDir);
//	mmView._42 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvYDir);
//	mmView._43 = -D3DXVec3Dot( (D3DXVECTOR3*)&mvEyePos, (D3DXVECTOR3*)&mvZDir);
//}
xGPCamera::xGPCamera():bIsFpc(vTrue)
{

}
TVoid xGPCamera::ChangeToFPC(TBool toFpc)
{
	if(toFpc == bIsFpc)return;
	else if(!toFpc){
		bIsFpc = vFalse;
		((xMVCamera*)this)->SetRadius(1.0f);
	}else{
		bIsFpc = vTrue;
	}
}
TVoid xGPCamera::RotateYRel( TFloat Angle )
{
	if(bIsFpc)
		((xFPCamera*)this)->RotateYRel(Angle);
	else
		((xMVCamera*)this)->RotateYRel(Angle);
}

TVoid xGPCamera::RotateRel( D3DXVECTOR3* pAxis,TFloat Angle )
{
	if(bIsFpc)
		((xFPCamera*)this)->RotateRel(pAxis,Angle);
	else
		((xMVCamera*)this)->RotateRel(pAxis,Angle);
}

TVoid xGPCamera::RotateXRel( TFloat Angle )
{
	if(bIsFpc)
		((xFPCamera*)this)->RotateXRel(Angle);
	else
		((xMVCamera*)this)->RotateXRel(Angle);
}

TVoid xGPCamera::RotateZRel( TFloat Angle )
{
	if(bIsFpc)
		((xFPCamera*)this)->RotateZRel(Angle);
	else
		((xMVCamera*)this)->RotateZRel(Angle);
}

TVoid xGPCamera::MoveZRel( TFloat Dist )
{
	if(bIsFpc)
		((xFPCamera*)this)->MoveZRel(Dist);
	else
		((xMVCamera*)this)->MoveZRel(Dist);
}

TVoid xGPCamera::MoveXRel( TFloat Dist )
{
	if(bIsFpc)
		((xFPCamera*)this)->MoveXRel(Dist);
	else
		((xMVCamera*)this)->MoveXRel(Dist);
}

TVoid xGPCamera::MoveYRel( TFloat Dist )
{
	if(bIsFpc)
		((xFPCamera*)this)->MoveYRel(Dist);
	else
		((xMVCamera*)this)->MoveYRel(Dist);
}

TVoid xGPCamera::MoveRel( D3DXVECTOR3* Dist )
{
	if(bIsFpc)
		((xFPCamera*)this)->MoveRel(Dist);
	else
		((xMVCamera*)this)->MoveRel(Dist);
}

TVoid xGPCamera::RotateXAbs( TFloat Angle )
{
	if(bIsFpc)
		((xFPCamera*)this)->RotateXAbs(Angle);
	else
		((xMVCamera*)this)->RotateXAbs(Angle);
}

TVoid xGPCamera::RotateYAbs( TFloat Angle )
{
	if(bIsFpc)
		((xFPCamera*)this)->RotateYAbs(Angle);
	else
		((xMVCamera*)this)->RotateYAbs(Angle);
}

TVoid xGPCamera::RotateZAbs( TFloat Angle )
{
	if(bIsFpc)
		((xFPCamera*)this)->RotateZAbs(Angle);
	else
		((xMVCamera*)this)->RotateZAbs(Angle);
}

TVoid xGPCamera::RotateAbs( D3DXVECTOR3* pAxis,TFloat Angle )
{
	if(bIsFpc)
		((xFPCamera*)this)->RotateAbs(pAxis,Angle);
	else
		((xMVCamera*)this)->RotateAbs(pAxis,Angle);
}

TVoid xGPCamera::MoveZAbs( TFloat Dist )
{
	if(bIsFpc)
		((xFPCamera*)this)->MoveZAbs(Dist);
	else
		((xMVCamera*)this)->MoveZAbs(Dist);
}

TVoid xGPCamera::MoveXAbs( TFloat Dist )
{
	if(bIsFpc)
		((xFPCamera*)this)->MoveXAbs(Dist);
	else
		((xMVCamera*)this)->MoveXAbs(Dist);
}

TVoid xGPCamera::MoveYAbs( TFloat Dist )
{
	if(bIsFpc)
		((xFPCamera*)this)->MoveYAbs(Dist);
	else
		((xMVCamera*)this)->MoveYAbs(Dist);
}

TVoid xGPCamera::MoveAbs( D3DXVECTOR3* Dist )
{
	if(bIsFpc)
		((xFPCamera*)this)->MoveAbs(Dist);
	else
		((xMVCamera*)this)->MoveAbs(Dist);
}